
/**
 * 创建一个tcp client连接
 */
WiFiClient tcpQtClient;
/**
   函数功能：上报属性至QT
   参数：jsonStr
*/
void reportQT(String jsonStr)
{
    StaticJsonDocument<1024> jsonData;

    while (tcpQtClient.connect(Host, Port))
    {
        DeserializationError error = deserializeJson(jsonData, jsonStr);
        if (error)
        {
            Serial.print(F("deserializeJson() failed: "));
            Serial.println(error.f_str());
            return;
        }
        char data[1024] = {0};
        sprintf(data, "Params{%s:%.2f;%s:%.2f;%s:%.2f;%s:%.2f;%s:%.2f;%s:%.2f;}",
                FLOAT_Temperature_ID, float(jsonData[FLOAT_Temperature_ID]),
                FLOAT_Humidity_ID, float(jsonData[FLOAT_Humidity_ID]),
                FLOAT_PH_ID, float(jsonData[FLOAT_PH_ID]),
                FLOAT_Turbidity_ID, float(jsonData[FLOAT_Turbidity_ID]),
                FLOAT_Hardness_ID, float(jsonData[FLOAT_Hardness_ID]),
                FLOAT_Sulfate_ID, float(jsonData[FLOAT_Sulfate_ID]));
        tcpQtClient.println(String(data));
#if debugState
        debugSerial.println("通过TCP协议向QT传输数据：\r\n[" + String(data) + "]");
#endif
        return;
    }
}